package com.taoyusen.common;

import javax.servlet.http.HttpServlet;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class InitializeSystemServlet extends HttpServlet
{

	public static WebApplicationContext context = null;
	
	
	/**
	 * �����
	 */
	public void init()
	{
		System.out.println("ϵͳ���ʼ...................");
		try
		{
			this.loadBeansConfig();
		}
		catch (RuntimeException e) 
		{
			e.printStackTrace();
		}
		System.out.println("ϵͳ�����...................");
	}
	
	/**
	 * ����bean
	 *
	 */
	public void loadBeansConfig()
	{
		context = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
	}
	
	
	public static Object getBeanByName(String beanName)
	{
		return context.getBean(beanName);
	}
}
